//
// Created by 86135 on 2025-06-24.
//

#ifndef COMPILER_CCV2_SYMBOL_TABLE_H
#define COMPILER_CCV2_SYMBOL_TABLE_H
#include "parser.h"

// 符号表项结构
typedef struct SymbolTableEntry {
    char* name;
    ASTNode* type;
    struct SymbolTableEntry* next;
} SymbolTableEntry;

// 符号表结构
typedef struct SymbolTable {
    SymbolTableEntry** entries;
    int size;
    struct SymbolTable* parent;
} SymbolTable;

// 初始化符号表
SymbolTable* initSymbolTable(SymbolTable* parent);
// 插入符号
void insertSymbol(SymbolTable* table, const char* name, ASTNode* type);
// 查找符号
SymbolTableEntry* lookupSymbol(SymbolTable* table, const char* name);
// 销毁符号表
void destroySymbolTable(SymbolTable* table);

#endif //COMPILER_CCV2_SYMBOL_TABLE_H
